package com.examsage.examsage.controller;

import com.examsage.examsage.model.TeachingPoint;
import com.examsage.examsage.model.vo.ResponseVO;
import com.examsage.examsage.service.ITeachingPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author examsage
 * @since 2025-07-02
 */
@RestController
@RequestMapping("/api/v1/teachingPoint")
public class TeachingPointController {
    @Autowired
    private ITeachingPointService teachingPointService;

    @PostMapping("/")
    public ResponseVO addTeachingPoint(TeachingPoint teachingPoint) {
        return teachingPointService.addTeachingPoint(teachingPoint);
    }

    @GetMapping("/")
    public ResponseVO getTeachingPoints(
        @RequestParam(defaultValue = "1") int page,
        @RequestParam(defaultValue = "10") int size,
        @RequestParam(required = false) String pointName,
        @RequestParam(required = false) Boolean status) {

        return teachingPointService.getTeachingPoint(page, size, pointName, status);
    }

    @PostMapping("/{id}")
    public ResponseVO updateTeachingPoint(@PathVariable("id") int id, TeachingPoint teachingPoint) {
        return teachingPointService.updateTeachingPoint(id, teachingPoint);
    }

    @DeleteMapping("/{id}")
    public ResponseVO deleteTeachingPoint(@PathVariable("id") int id) {
        return teachingPointService.deleteTeachingPoint(id);
    }

}
